<template>
    <div style="display: flex; flex-direction: row;width: 100%;height: 90vh; ">
        <!-- 上部分地图 -->
          <testMap :center="center"  ref="testMapRef"></testMap>
    </div>
  </template>
  <script>
  // import testMap from "./components/Smap.vue";
  import testMap from "@/components/baiduMap/index.vue";

  import { getImageInfo } from "@/api/system/info";
  export default {
    components: {
      testMap,
    },
    data() {
      return {
        center: {
          lng: "121.43943786621094",
          lat: "31.203404950917385",
        },
        form: {},
        ipList: [],//经纬度列表
      };
    },
    computed: {

    },
    mounted() {
      //从地址获取ID
      const id = this.$route.query.id;
      //调用查询详情的接口
      getImageInfo(id).then((res) => {
        console.log(res);
        if (res.code == 200) {
            if(res.rows.length > 0){
                this.ipList = res.rows;
                this.center={
                    lng:  res.rows[0].lon,
                    lat:  res.rows[0].lat,
                }
                console.log(this.center);
            }else{
                //提示信息  然后返回上一页
                this.$message.error("暂无经纬度信息");
                this.$router.go(-1);
            }
        } else {
          this.$message.error("获取用户数据失败！");
          this.form = {};
        }
      });
      setTimeout(() => {
        this.$refs.testMapRef.setData({
            points: this.ipList.map(item => ({
                lng: item.lon,
                lat: item.lat,
                ...item
              }))
        });
      }, 2000);
    },

    methods: {

    },
  };
  </script>
